<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>发微博</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        html {
            height: 100%;
        }
        body {
            height: 100%;
        }
        .container {
            height: 100%;
            background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);
        }
        .login-wrapper {
            background-color: #fff;
            width: 358px;
            height: 588px;
            border-radius: 15px;
            padding: 0 50px;
            position: relative;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }
        .header {
            font-size: 38px;
            font-weight: bold;
            text-align: center;
            line-height: 200px;
        }
        .input-item {
            display: block;
            width: 100%;
            margin-bottom: 20px;
            border: 0;
            padding: 10px;
            border-bottom: 1px solid rgb(128, 125, 125);
            font-size: 15px;
            outline: none;
        }
        .input-item::placeholder {
            text-transform: uppercase;
        }
        .btn {
            text-align: center;
            padding: 10px;
            width: 100%;
            margin-top: 40px;
            background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
            color: #fff;
        }
        .msg {
            text-align: center;
            line-height: 88px;
        }
        a {
            text-decoration-line: none;
            color: #abc1ee;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="login-wrapper">
        <div class="header">发微博</div>
        <div class="form-wrapper">
            <textarea class="input-item" cols="30" rows="4" placeholder="说点儿啥..." v-model="weibo.content"></textarea>
            <div class="btn" @click="insert()">发微博</div>
        </div>
        <div class="msg">
            请先登录？
            <a href="/login.html">登录</a>
        </div>
    </div>
</div>

<!-- 引入axios和Vue框架文件 -->
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
<!-- 导入Vue -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- 导入Element UI -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    new Vue({
        el: '#app',
        data: function () {
            return {
                weibo: {
                    content: ''
                }
            };
        },
        methods: {
            insert() {
                axios.post("/v1/weibo/insert", this.weibo)
                    .then(response => {
                        if (response.data === 1) {
                            location.href = "/"; // 回到首页
                        } else {
                            alert("请先登录!");
                            location.href = "/login.html";
                        }
                    });
            }
        }
    });
</script>
</body>
</html>
